package com.dqx.haoqiu.repository.repository.user.local;

import com.dqx.haoqiu.repository.entity.TokenEntity;
import com.dqx.haoqiu.repository.entity.UserEntity;
import com.dqx.haoqiu.repository.repository.user.UserSource;
import com.xmjs.baselibrary.utils.SP;

import javax.inject.Inject;

import io.reactivex.Observable;

import static com.dqx.haoqiu.repository.constans.IConstants.SHOW_APP_GUIDE;
import static com.dqx.haoqiu.repository.constans.IConstants.SHOW_PRIVACY_DIALOG;

/**
 * 本地数据源：可以用来存取本地缓存的数据，可以结合SharePrefence或本地数据库Room等框架
 */
public class UserLocalSource implements UserSource {

    private SP mSP;

    @Inject
    public UserLocalSource(SP sp) {
        mSP = sp;
    }

    @Override
    public Observable<TokenEntity> login(String username, String password) {
        return null;
    }

    @Override
    public Observable<UserEntity> getUserInfo() {
        return null;
    }

    @Override
    public void setShowGuide(boolean show) {
        mSP.putBoolean(SHOW_APP_GUIDE, show);
    }

    @Override
    public boolean showGuide() {
        return mSP.getBoolean(SHOW_APP_GUIDE, true);
    }

    @Override
    public void setShowPrivaceDialog(boolean show) {
        mSP.putBoolean(SHOW_PRIVACY_DIALOG, show);
    }

    @Override
    public boolean showPrivaceDialog() {
        return mSP.getBoolean(SHOW_PRIVACY_DIALOG, true);
    }
}